#pragma once

#include "SFML\Graphics.hpp"
#include "WorldObject.h"
#include "SpriteManager.h"

class Agent;
class Node
{
	public:
		enum ObjectTypes
		{
			TreeType1,
			TreeType2,
			RockType1,
			RockType2,
			BushType1
		};

		// Position of node in the grid
		sf::Vector2i m_vID;
		
		// Position of node in the world
		sf::Vector2f m_vPosition;

		// Connections N-0, S-1, W-2, E-3, (NE-4, SE-5, SW-6, NW-7)
		std::vector<Node*> m_xAdjacentNodes;

		// Rectangle
		sf::RectangleShape* m_xRect;

		// Sprite, Tree/Rock etc.
		sf::Sprite* m_xObjectSprite;

		// Sprite, Tree/Rock etc.
		sf::Sprite* m_xGroundSprite;

		// If the node is walkable
		bool m_bBlocked = false;

		// World object, plant or w/e. Can only hold one world object
		WorldObject* m_xWorldObject = nullptr;

		// List of animals on the node
		std::vector<Agent*> m_vAgents;

		/** Variables for the pathfinding */
		Node* m_ParentNode = nullptr;

		//Current Path Cost
		int m_iGCost = 0;
		
		//Distance from goal in manhattan units
		int m_iHCost = 0;
		
		//Total Cost	
		int m_iFCost = 0;
		
		//Am i on open list
		bool m_bIsOnOpenList = false;
		
		//Am i on closed list
		bool m_bIsOnClosedList = false;

		void LoadObjectSprite(ObjectTypes pObject);
		void LoadGroundTile();
		void AddAgent(Agent* pAgent);
		void RemoveAgent(Agent* pAgent);
};